<template>
    <div>
        <el-button @click="login">默认按钮</el-button>
        {{ token }}

    </div>
</template>

<script>

import axios from "axios";

export default {

    data() {
        return {
            token: '',
            user_id: ''


        }
    },

    methods: {
        login() {
            axios
                .post('/api/user/login', {
                    username: "1234",
                    password: "1234"
                    // password: "jiangweike@19991",
                })
                .then(response => {
                    console.log(response);
                    console.log(response.data.data);

                    // if (response.data.data == 0) {
                    //     window.alert("账号或密码错误！");
                    //     LoginName.value = '';
                    //     LoginPassword.value = '';
                    // }

                    // window.alert("登录成功！");
                    localStorage.setItem('userToken', response.data.data.token);
                    console.log(localStorage.getItem('userToken'));
                    this.token = response.data.data.token
                    // localStorage.setItem('userName', LoginName);
                    // localStorage.setItem('userPicture', response.data.data.userDetails.url);
                    localStorage.setItem('userId', response.data.data.userDetails.id);
                    // router.push({ path: '/' });

                })
                .catch(function (error) { // 请求失败处理
                    console.log(error);
                });

        }

    }
}
</script>

<style scoped></style>
